package board;

import piece.Piece;

public class BoardTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Test 
		// Generate a board object
		Board boardtest = new Board();
		
		// Generate several pieces
		// create a Marshal, a miner, a scout for BLUE
		Piece marshal1 = Piece.createPiece(Piece.RANK_MARSHAL, Piece.COLOR_BLUE);
		Piece miner1 = Piece.createPiece(Piece.RANK_MINER, Piece.COLOR_BLUE);
		Piece scout1 = Piece.createPiece(Piece.RANK_SCOUT, Piece.COLOR_BLUE);
		
		// creat a Gerneral, a miner, a bomb for RED
		Piece general2 = Piece.createPiece(Piece.RANK_GENERAL, Piece.COLOR_RED);
		Piece miner2 = Piece.createPiece(Piece.RANK_MINER, Piece.COLOR_RED);
		Piece bomb2 = Piece.createPiece(Piece.RANK_BOMB, Piece.COLOR_RED);
		
		// setting these pieces into the upper left board like following
		/* -----------------------------
		   marshal1 --- miner1  --- miner2 
			  |      |	bomb2    |   |
		   general2 --- scout1  ---  ---
		   ------------------------------
		*/ 
		//try {
			boardtest.setPiece(0, 0, marshal1);
			boardtest.setPiece(0, 2, miner1);
			boardtest.setPiece(0, 4, miner2);
			boardtest.setPiece(1, 2, bomb2);
			boardtest.setPiece(2, 0, general2);
			boardtest.setPiece(2, 2, scout1);
		//} catch (Exception e) {
		    
		//}
		
		//test on getPiece
		Piece pick1 = boardtest.getPiece(0, 0);
		Piece pick2 = boardtest.getPiece(0, 1);
		System.out.println("pick1 is: " + pick1);
		System.out.println("pick1 is actually a piece: " + (pick1 != null));
		System.out.println("pick1's color is: " + pick1.getColor());
		
		System.out.println("pick2 is actually a piece: " + (pick2 != null));
		
		// test on move
		// pick not in board
		System.out.println("try to pick out of board: " + boardtest.move(-1, 1, 0, 3));
		// pick null piece
		System.out.println("try to move null: " + boardtest.move(0, 1, 0, 3));
		// move the immovable piece bomber2
		System.out.println("try to move miner1: " + boardtest.move(1, 2, 0, 3));
		// move the miner1 to miner2
		System.out.println("try to move miner1 to miner2: " + boardtest.move(0, 2, 0, 4));
		// move the scount1 to marshal1
		//System.out.println("pick1 is: " + boardtest.getPiece(2, 2).getMoveDistance());
		System.out.println("try to move scount1 to marshal1: " + boardtest.move(2, 2, 0, 0));
		// move the scount1 to [1,0]
		System.out.println("try to move scount1 to marshal1: " + boardtest.move(2, 2, 1, 0));
		
		// move the miner1 to bomb2
		System.out.println("try to move scount1 to marshal1: " + boardtest.move(0, 2, 1, 2));
	}	

}
